/*
 * Copyright (C) 2018 guomw.Inc. All rights reserved.
 * 项目名称： report-manage
 * 文件名称： LocalDateTimeUtils.java
 * Date：18-11-5 上午10:54
 * Author: guomw
 */

package com.guomw.report.common.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @author guomw
 * @date 2018/10/16
 */
public class LocalDateTimeUtils {

    public static LocalDateTime parse(String dateText) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date = simpleDateFormat.parse(dateText);
            Instant instant = date.toInstant();
            ZoneId zone = ZoneId.systemDefault();
            return LocalDateTime.ofInstant(instant, zone);
        } catch (ParseException px) {
            px.printStackTrace();
        }
        return LocalDateTime.now();
    }
}
